perf: cache hardware detection and optimize warm-path reuse (2/4)#1252
Open
davidberenstein1957 wants to merge 5 commits into
Open
perf: cache hardware detection and optimize warm-path reuse (2/4)#1252davidberenstein1957 wants to merge 5 commits into
davidberenstein1957 wants to merge 5 commits into
Conversation
Lazy-load reference data, output handlers, hardware probing, and the emissions engine so tracker construction stays fast when work is deferred. Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Jun 21, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## davidberenstein1957/perf-1-lazy-init #1252 +/- ##
========================================================================
- Coverage 89.39% 89.27% -0.12%
========================================================================
Files 47 48 +1
Lines 4565 4757 +192
========================================================================
+ Hits 4081 4247 +166
- Misses 484 510 +26 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
Author
Deferred hardware setup in PR 1 requires _ensure_hardware_ready() in tests that inspect tracker._hardware before start(). Co-authored-by: Cursor <cursoragent@cursor.com>
1f759d9 to
9d1c656
Compare
Collaborator
Author
|
Rebased on #1251 + conftest hardening to reset probe Verified locally: 530 passed, pre-commit clean. |
Use TYPE_CHECKING import for pd so lazy loading stays fast while keeping return type annotations on get_cloud_emissions_data and get_cpu_power_data. Co-authored-by: Cursor <cursoragent@cursor.com>
Add process-level hardware setup cache, probe result caching, platform-aware CPU backend selection, and parallel CPU/GPU setup for faster repeat runs. Co-authored-by: Cursor <cursoragent@cursor.com>
Import GPU/CPU probe modules before clearing caches so lru_cache state does not leak across tests in the full suite. Co-authored-by: Cursor <cursoragent@cursor.com>
9d1c656 to
00817d8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part 2/4 of the tracker performance stack. Depends on #1251.
cc @inimaz — this is the hardware-cache layer of the #1246 split.
Adds process-level hardware reuse and faster detection so repeat tracker runs in the same Python process skip repeated probing:
hardware_cache.pywithHardwareKindenum and per-process setup cacheget_or_run_setup)@lru_cache(Power Gadget, PowerMetrics, NVIDIA, ROCm)cpu_loadbefore PowerMetrics)ThreadPoolExecutorcpu_percentprime once per process forcpu_loadmodeBenchmarks (measured locally, offline Mac ARM, 2026-06-21)
Cumulative with #1251; fresh subprocess for cold metrics.
__init__p50init→start→stop)Stack
CI / quality
pre-commit runon all changed files — passedpytest tests/test_hardware_cache.py tests/test_resource_tracker.py tests/test_cpu.py tests/test_powermetrics.py tests/test_gpu.py— 106 passedTest plan
Replaces
Split from #1246.